package cn.zwk.cli;

import cn.zwk.config.ConfigLoader;
import cn.zwk.config.PipelineConfig;
import cn.zwk.orchestrator.PipelineOrchestrator;
import cn.zwk.orchestrator.model.ReportPayload;

import java.nio.file.Path;

public class RunPipeline {
    public static void main(String[] args) {
        if (args.length < 1) {
            System.out.println("Usage: java -cp target/classes cn.zwk.cli.RunPipeline <pipeline.yaml>");
            System.exit(2);
        }
        Path cfgPath = Path.of(args[0]);
        PipelineConfig cfg = ConfigLoader.load(cfgPath);

        PipelineOrchestrator orch = new PipelineOrchestrator();
        ReportPayload report = orch.execute(cfg);

        Path template = Path.of(cfg.getOutputTemplateFile());
        Path out = Path.of(cfg.getOutputFile());
        orch.writeReport(report, template, out);

        System.out.println("Report generated: " + out.toAbsolutePath());
    }
}

